﻿   --NKNH_LoadLuoiGuiNH  2      
    --  select * from NKNH_H h inner join NKNH_L l on h.so_ctu=l.so_ctu      
     -- where h.tk_co='1121'       
CREATE proc [dbo].[NKNH_LoadLuoiGuiNH]-- 1--'3400009324'      
           
 @bien int        
       
as            
   if(@bien=1)        
begin            
/*select distinct a.so_ctu,h.ngay_ctu,h.tk_no as tk_no,h.chitiet_tkno as chitiet_no,            
  l.tk as tk_co,l.chitiet_tk as chitiet_co,h.hoten as nguoichungtu,            
  h.noi_dung as diengiai,a.Sophatsinh,a.tien_vat  */          
  select distinct(h.so_ctu),h.ngay_ctu,h.tk_no,h.chitiet_tkno,l.tk as tk_co,l.chitiet_tk as chitiet_co,          
  l.so_tien as sophatsinh,l.tien_vat ,h.hoten as nguoichungtu,h.noi_dung as diengiai          
   from NKNH_H h inner join NKNH_L l on h.NHID=l.NHID        
   where h.tk_no in('1121','1122')          
end          
else if(@bien=2)        
begin        
select distinct(h.so_ctu),h.ngay_ctu,h.tk_co,h.chitiet_tkco as chitiet_co,l.tk as tk_no,l.chitiet_tk as chitiet_tkno,          
  l.so_tien as sophatsinh,l.tien_vat,h.hoten as nguoichungtu,h.noi_dung as diengiai          
   from NKNH_H h inner join NKNH_L l on h.NHID=l.NHID           
   where h.tk_co in('1121','1122')        
end 